<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>欢迎页面-X-admin2.0</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="./css/font.css">
		<link rel="stylesheet" href="./css/xadmin.css">
		<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="./js/xadmin.js"></script>
		<script type="text/javascript" src="js/myself.js"></script>
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
	</head>

	<body >
		<form class="layui-form" id="editForm">
			<div class="layui-form-item">
				<input type="text" id="carId" name="carId" style="display: none;" autocomplete="off" class="layui-input">
				<div class="layui-inline">
					<label class="layui-form-label">品牌:</label>
					<div class="layui-input-inline">
						<select name="brand" id="brand">
							<option>大众</option>
							<option>奔驰</option>
							<option>宝马</option>
							<option>别克</option>
							<option>红旗</option>
							<option>五菱</option>
							<option>雪佛兰</option>
							<option>捷豹</option>
							<option>特斯拉</option>
						</select>
					</div>
					<label class="layui-form-label">型号:</label>
					<div class="layui-input-inline">
						<input type="text" id="model" name="model" autocomplete="off" class="layui-input">
					</div>
					<label class="layui-form-label">汽车颜色:</label>
					<div class="layui-input-inline">
						<select name="color" id="color">
							<option>红色</option>
							<option>白色</option>
							<option>黑色</option>
							<option>蓝色</option>
							<option>棕色</option>
							<option>其他</option>
						</select>
					</div>

				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">汽车类型:</label>
				<div class="layui-input-inline">
					<select name="type" id="type">
						<option value="">选择汽车类型</option>
						<option>轿车</option>
						<option>跑车</option>
						<option>商务车</option>
						<option>越野车</option>
						<option>电动车</option>
					</select>
				</div>
				<label for="seatNum" class="layui-form-label">座位数
				</label>
				<div class="layui-input-inline">
					<input type="text" id="seatNum" name="seatNum" autocomplete="off" class="layui-input">
				</div>

			</div>
			<div class="layui-form-item">
				<label for="usedTime" class="layui-form-label">
					车龄（年）
				</label>
				<div class="layui-input-inline">
					<input type="text" id="usedTime" name="usedTime" autocomplete="off" class="layui-input">
				</div>
				<label for="milage" class="layui-form-label">
					行驶里程（万里）
				</label>
				<div class="layui-input-inline">
					<input id="mileage" name="mileage" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">是否上架:</label>
					<div class="layui-input-inline">
						<select name="sale" id="sale">
							<option value="1">是</option>
							<option value="0">否</option>
						</select>
					</div>
					<label class="layui-form-label">交易类型:</label>
					<div class="layui-input-inline">
						<select name="saleType" id="saleType">
							<option value="0">寄售</option>
							<option value="1">求购</option>
						</select>
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<label for="note" class="layui-form-label">
					<span class="x-red">*</span>备注(卖家手机号码)
				</label>
				<div class="layui-input-inline">
					<input type="text" id="note" name="note" autocomplete="off" class="layui-input">
				</div>
				<label class="layui-form-label" style="font-size: 16px;">
					<span class="x-red">*</span>标价:
				</label>
				<div class="layui-input-inline" style="width: 100px;">
					<input type="text" id="price" name="price" placeholder="￥" autocomplete="off" class="layui-input">
				</div>
				<div class="layui-form-mid">万</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">上传封面照片</label>
				<div class="layui-input-inline uploadHeadImage">
					<div class="layui-upload-drag" id="carPic">
						<i class="layui-icon"></i>
						<img src="" alt="暂无图片" id="picture0" height="100px" width="130px" class="layui-upload-img uploadImgPreView">
					</div>
				</div>
				预览图：
				<div class="layui-upload-list" id="see0"></div>
			
				<input type="text" id="picture" name="picture" style="display: none;" class="layui-input">
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">上传车况图1</label>
				<div class="layui-input-inline uploadHeadImage">
					<div class="layui-upload-drag" id="carPic1">
						<i class="layui-icon"></i>
						<img src="" alt="暂无图片" id="picture1" height="100px" width="130px" class="layui-upload-img uploadImgPreView">
					</div>
				</div>
				预览图：
				<div class="layui-upload-list" id="see1" ></div>
				<input type="text" id="picture1Path" name="picture1Path" style="display: none;" class="layui-input">
			</div>
			<div class="layui-form-item">	
					<label class="layui-form-label">上传车况图2</label>
				<div class="layui-input-inline uploadHeadImage">
					<div class="layui-upload-drag" id="carPic2">
						<i class="layui-icon"></i>
						<img src="" alt="暂无图片" id="picture2" height="100px" width="130px" class="layui-upload-img uploadImgPreView">
					</div>
				</div>
				预览图：
				<div class="layui-upload-list" id="see2"></div>
				<input type="text" id="picture2Path" name="picture2Path" style="display: none;" class="layui-input">
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="button" onclick="doSave();" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					<div id="rigisterHint" style="color:red"></div>
				</div>
			</div>
		</form>
	</body>
	<script>
		var date = eval('('+parent.json+')');//获取父级参数
		console.log(date);
		//选择框赋值
		$("#brand").val(date.brand);
		$("#color").val(date.color);
		$("#sale").val(date.sale);
		$("#saleType").val(date.saleType);
		$("#type").val(date.type);
		layui.use('form', function () {
		     var $ = layui.jquery, form = layui.form;
			 form.render();
		    });
		//提交表单
		function doSave() {
			var data = $("#editForm").serialize();
			$.post("http://localhost:8888/usedcar/car/edit?token="+document.cookie.split(";")[0], data, function(response) {
				console.log(response);
				if (response == 1) {
					console.log("提交表单了！");
					layer.alert("修改成功", {
						yes: function() {
							parent.layer.closeAll();
						}
					});
				}
			});
		}
	</script>

</html>
